#include <iostream>
#define N 100

using namespace std;

void readintVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}

int distinct_nr(int array[], int elements){
int i, j, k, valid;
for (i=0;i<elements;i++){
    valid=false;
    for (j=i+1; j<elements;j++){
        if(array[i]==array[j]){
            valid=true;
            for(k=j;k<elements;k++)
                array[k]=array[k+1];
            --elements;

        }
    }
    if (valid==true){
        for(k=i;k<elements;k++)
            array[k]=array[k+1];
        --elements;
        }
    if (valid==true && i==0)
        --i;
}
return elements;
}

void printintVector(int array[], int elements){
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
	cout<<"\n";
}



int main(){
int array[N];
int elements;
cout<<"Type the number of elements you want in the array: ";
cin>>elements;

readintVector(array, elements);

cout<<"The original array is ";
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
cout<<endl;

elements=distinct_nr(array, elements);

cout<<"The array with duplicates removed is: ";

printintVector(array ,elements);

return 0;
}
